/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ebm;

import DB.DBFunctions;
import bean.Autore;
import bean.TellicoObj;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 *
 * @author vincenzoscognamiglio
 */
public class CreateAuthorFromFromTellico {

    public static void main(String[] args) {
        try {
            Connection conn = DBFunctions.createConnection();
            String querySQL = "SELECT DISTINCT AUTORE FROM APP.TELLICO_IMPORT";
            PreparedStatement psquery = conn.prepareStatement(querySQL);
            ResultSet rs = psquery.executeQuery();
            while (rs.next()) {
                
                String autName = rs.getString("AUTORE");
                Autore aut = TellicoObj.createAutoreObj(autName);
                DBFunctions.insertAutore(aut);
                System.out.println("Aggiunto:"  + autName);    
            }
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }



    }
}
